from django.core.management.base import BaseCommand
import time, lib.workflow
import settings

class Command(BaseCommand):
    print 'python-strike server is online'
    wf = lib.workflow.Workflow()
    while True:
        quantity = wf.count_tasks()
        if not quantity:
            print '#'*10,'sleeping ['+str(settings.STIME)+']','#'*10
        else:
            print '#'*10,'working ['+str(quantity)+']','#'*10
            wf.mapreduce()
        time.sleep(settings.STIME)


